#!/usr/bin/perl -w
print "Content-type:text/html\n";

$username = $ARGV[0];     #Take in arguments from testlog.php
$pass     = $ARGV[1];

#Escapes Metacharacters
$pass =~ s/\+/\\+/g;              #Escape the + sign
$pass =~ s/\(/\\(/g;              #Escape the ( sign
$pass =~ s/\)/\\)/g;              #Escape the ) sign
$pass =~ s/\[/\\[/g;              #Escape the [ sign
$pass =~ s/\]/\\]/g;              #Escape the ] sign
#$pass =~ s/\\/\\\/g;             #Escape the \ sign
$pass =~ s/\{/\\{/g;              #Escape the { sign
$pass =~ s/\}/\\}/g;              #Escape the } sign
$pass =~ s/\^/\\^/g;              #Escape the ^ sign
$pass =~ s/\*/\\*/g;              #Escape the * sign
$pass =~ s/\?/\\?/g;              #Escape the ? sign
$pass =~ s/\./\\./g;              #Escape the . sign

open ($info, "../../admin/users/users.txt") or die "Died";	# Open the file
while (<$info>)   # Read a line
{	
   # not a comment neither a white line neither white space character

     if (/(\s*$username\s*)\|                   #Match username  ($1)      
	         (\s*$pass\s*)\|                   #Match password  ($2)
		     (\w+\s*\w+)+\|                   #Set value of Full name to $3
         \s*(\d{4}-\d{1,2}-\d{1,2})?\s*\|                   #Set value of date YYYY-MM-DD to $4
		     (\s*\w+\s*)?\|                   #Set value of country to $5
   (\s*\w+\s*(,\s*\w+\s*)*)\|                   #Set groups to $6
            (\s*[[:alnum:]]*)                   #Set client id to $8
	          \s*(\#.*)?$/x)                   #End Comments

	{

		print "$6"."\n"; #Return groups to testlog.php
          print "$8"."\n"; #Return client id to testlog.php
		exit(9);
	}
	else
	{
		#print "Not Working\n";
	}
}
close($info);			# Close the file





